Skip to content

CMakeLists: rename version to VERSION to avoid shadowing C++20 <version> - #570

Open
heitbaum wants to merge 1 commit into
jgarff:masterfrom
heitbaum:version
Open

CMakeLists: rename version to VERSION to avoid shadowing C++20 <version>#570
heitbaum wants to merge 1 commit into
jgarff:masterfrom
heitbaum:version

Conversation

@heitbaum

Copy link
Copy Markdown

Problem

The file named version in the repository root contains the plain-text project version string ("1.1.0") and is read by CMakeLists.txt at configure time:

file(READ version PROJECT_VERSION)

When rpi_ws281x is used as a CMake subdirectory of a C++20 project, the subdirectory's source path is typically added to the compiler include search path so that the library headers (ws2811.h, rpihw.h, etc.) can be found with angle-bracket includes. On any compiler that implements C++20, the <version> feature-test header is part of the standard library. When a translation unit (directly, or through a transitively included header) does:

#include <version>

the preprocessor searches the include path in order. If the rpi_ws281x source directory appears on that path before the toolchain's system include directory, the compiler opens the plain-text version file instead of the C++20 standard library header. Attempting to parse "1.1.0" as C++ source is a hard error:

error: stray '.' in program

Fix

Rename version to VERSION. On Linux (and all other case-sensitive filesystems) VERSION and version are distinct names; the compiler looking for <version> will no longer find the version data file.

Update the single file(READ ...) call in CMakeLists.txt accordingly. No other file in this repository references the plain name version as a path: version.h.in and version.py are separate files with different names and are unaffected.

Impact

Behaviour is identical for all existing build methods (CMake, SCons). The only observable change is the filename on disk; the content and the PROJECT_VERSION variable it populates are unchanged.

Problem
-------
The file named `version` in the repository root contains the plain-text
project version string ("1.1.0") and is read by CMakeLists.txt at
configure time:

    file(READ version PROJECT_VERSION)

When rpi_ws281x is used as a CMake subdirectory of a C++20 project, the
subdirectory's source path is typically added to the compiler include
search path so that the library headers (ws2811.h, rpihw.h, etc.) can be
found with angle-bracket includes.  On any compiler that implements C++20,
the `<version>` feature-test header is part of the standard library.  When
a translation unit (directly, or through a transitively included header)
does:

    #include <version>

the preprocessor searches the include path in order.  If the rpi_ws281x
source directory appears on that path before the toolchain's system include
directory, the compiler opens the plain-text `version` file instead of the
C++20 standard library header.  Attempting to parse "1.1.0" as C++ source
is a hard error:

    error: stray '.' in program

Fix
---
Rename `version` to `VERSION`.  On Linux (and all other case-sensitive
filesystems) `VERSION` and `version` are distinct names; the compiler
looking for `<version>` will no longer find the version data file.

Update the single `file(READ ...)` call in CMakeLists.txt accordingly.
No other file in this repository references the plain name `version` as a
path: `version.h.in` and `version.py` are separate files with different
names and are unaffected.

Impact
------
Behaviour is identical for all existing build methods (CMake, SCons).  The
only observable change is the filename on disk; the content and the
PROJECT_VERSION variable it populates are unchanged.
heitbaum added a commit to heitbaum/LibreELEC.tv that referenced this pull request Jun 11, 2026
The source tree ships a plain-text version file in its root directory.
When the directory is on a compiler include path, #include <version> (used
by Qt5's qstdlibdetection.h) finds this file instead of the C++ standard
library header and fails to compile with "error: stray '.' in program".

Carry a patch to rename version to VERSION (safe on case-sensitive Linux)
and update the file(READ) call in CMakeLists.txt. hyperhdr processes
rpi_ws281x via add_subdirectory so cmake still reads the version data;
hyperion compiles the sources directly and is unaffected either way.

Patch submitted upstream: jgarff/rpi_ws281x#570
Drop this patch when the upstream PR is merged and PKG_VERSION is bumped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant